package net.lab1024.sa.admin.module.business.yct.yctTeeth.controller;

import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.DialogueAddForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.DialogueQueryForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.DialogueUpdateForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.vo.DialogueVO;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.service.DialogueService;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 聊天信息 Controller
 *
 * @Author zhangben
 * @Date 2024-12-20 11:07:08
 * @Copyright 20241218
 */

@RestController
@Tag(name = "聊天信息")
public class DialogueController {

    @Resource
    private DialogueService dialogueService;

    @Operation(summary = "分页查询 @author zhangben")
    @PostMapping("/dialogue/queryPage")
    @SaCheckPermission("dialogue:query")
    public ResponseDTO<PageResult<DialogueVO>> queryPage(@RequestBody @Valid DialogueQueryForm queryForm) {
        return ResponseDTO.ok(dialogueService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author zhangben")
    @PostMapping("/dialogue/add")
    @NoNeedLogin
    public ResponseDTO<String> add(@RequestBody @Valid DialogueAddForm addForm) {
        return dialogueService.add(addForm);
    }

    @Operation(summary = "更新 @author zhangben")
    @PostMapping("/dialogue/update")
    @SaCheckPermission("dialogue:update")
    public ResponseDTO<String> update(@RequestBody @Valid DialogueUpdateForm updateForm) {
        return dialogueService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author zhangben")
    @PostMapping("/dialogue/batchDelete")
    @SaCheckPermission("dialogue:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return dialogueService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author zhangben")
    @GetMapping("/dialogue/delete/{dialogueId}")
    @SaCheckPermission("dialogue:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer dialogueId) {
        return dialogueService.delete(dialogueId);
    }

    @NoNeedLogin
    @PostMapping("/dialogue/queryPageMsg")
    public ResponseDTO<PageResult<DialogueVO>> queryPageMsg(@RequestBody @Valid DialogueQueryForm queryForm) {
        return ResponseDTO.ok(dialogueService.queryPageMsg(queryForm));
    }


}
